package com.itheima.manager;

import com.itheima.common.R;
import com.itheima.domain.OmsMoneyInfoParam;
import com.itheima.domain.OmsOrderReturnReason;
import com.itheima.domain.OmsOrderSetting;
import com.itheima.service.db.IOrderService;
import com.itheima.vo.*;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class OmsOrderManager {

    @DubboReference
    IOrderService iOrderService;

    public R orderDelete(Integer[] ids) {
        Boolean delete = iOrderService.orderDelete(ids);
        if (delete){
            return R.success(delete);
        }else {
            return R.error("无法删除");
        }

    }

    public R<PageBeanVo> findOrderList(String createTime, String orderSn, Integer orderType, Integer pageNum, Integer pageSize, String receiverKeyword, Integer sourceType, Integer status) {
        PageBeanVo orderList = iOrderService.findOrderList(createTime, orderSn, orderType, pageNum, pageSize, receiverKeyword, sourceType, status);
        return R.success(orderList);
    }

    public R orderClose(Integer[] ids,String note) {
        Boolean close = iOrderService.orderClose(ids);
        if (close){
            return R.success(close);
        }else {
            return R.error("无法关闭");
        }
    }

    public R orderSend(List<OmsOrderVo> deliveryParamList) {
        Boolean send = iOrderService.orderSend(deliveryParamList);
        if (send){
            return R.success(send);
        }else {
            return R.error("无法发货");
        }
    }

    public R orderFindById(Integer id) {
        return R.success(iOrderService.orderFindById(id));
    }

    public R orderNote(Integer id, String note, Integer status) {
        return R.success(iOrderService.orderNote(id,note,status));
    }

    public R orderUpdatePeopel(OmsReceiverInfoParam receiverInfoParam) {
        iOrderService.orderUpdatePeopel(receiverInfoParam);
        return R.success(true);
    }

    public R returnApplyByPage(String createTime, String handleMan, String handleTime, Integer id, Integer pageNum, Integer pageSize, String receiverKeyword, Integer status) {
        return R.success(iOrderService.returnApplyByPage(createTime,handleMan,handleTime,id,pageNum,pageSize,receiverKeyword,status));
    }

    public R returnApplyDelete(Integer[] ids) {
        Boolean delete = iOrderService.returnApplyDelete(ids);
        if (delete){
            return R.success(delete);
        }else {
            return R.error("不能删除");
        }

    }

    public R returnApplyById(Integer id) {
        OmsOrderReturnApplyVo omsOrderReturnApplyVo = iOrderService.returnApplyById(id);
        return R.success(omsOrderReturnApplyVo);
    }

    public R returnApplyUpdate(Integer id, OmsUpdateStatusParam statusParam) {
        iOrderService.returnApplyUpdate(id,statusParam);
        return R.success(null);
    }

    public R returnReasonSave(OmsOrderReturnReason returnReason) {
        iOrderService.returnReasonSave(returnReason);
        return R.success(null);
    }

    public R<PageBeanVo> returnReasonByPage(Integer pageNum, Integer pageSize) {
        PageBeanVo pageBeanVo=iOrderService.returnReasonByPage(pageNum,pageSize);
        return R.success(pageBeanVo);
    }

    public R returnReasonDeleteByIds(Integer[] ids) {
        iOrderService.returnReasonDeleteByIds(ids);
        return R.success(null);
    }

    public R returnReasonUpdateStatus(Integer[] ids, Integer status) {
        iOrderService.returnReasonUpdateStatus(ids,status);
        return R.success(null);
    }

    public R returnReasonUpdateReason(OmsOrderReturnReason returnReason) {
        iOrderService.returnReasonUpdateReason(returnReason);
        return R.success(null);
    }

    public R returnReasonSelectById(Integer id) {
        OmsOrderReturnReason omsOrderReturnReason = iOrderService.returnReasonSelectById(id);
        return R.success(omsOrderReturnReason);
    }

    public R omsOrderSettingfindById(Integer id) {
        OmsOrderSetting omsOrderSetting = iOrderService.omsOrderSettingfindById(id);
        return R.success(omsOrderSetting);
    }

    public R omsOrderSettingUpdate(Integer id, OmsOrderSetting orderSetting) {
        iOrderService.omsOrderSettingUpdate(id,orderSetting);
        return R.success(null);
    }

    public R orderUpdateMoney(OmsMoneyInfoParam moneyInfoParam) {
        iOrderService.orderUpdateMoney(moneyInfoParam);
        return R.success(null);
    }
}
